<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <div th:include="common/head_info::head_infor"></div>
    <script type="text/javascript" th:src="@{../js/messageMangerment.js}"></script>
</head>
<body>
<div class="container center" style="margin-top: 20px;">
    <div class="panel panel-default" id="document">
        <!-- Default panel contents -->
        <div class="panel-heading">消息管理
            <button style="float: right" class="btn btn-default" type="button" data-target="#exampleModalInsert"
                    data-toggle="modal">新增消息
            </button>
        </div>
        <!--消息内容-->
        <div style="margin-top: 15px" id="messageShow"></div>

        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">×</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">消息编辑</h4>
                    </div>
                    <div class="modal-body">
                        <form role="form">
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="ustatus">状态</label>
                                    <select class="form-control " id="ustatus">
                                        <option value="0">禁用</option>
                                        <option value="1" selected>启用</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="umessage">消息</label>
                                    <textarea class="form-control" rows="3" id="umessage"></textarea>
                                </div>
                            </div>
                        </form>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" onclick="updataDate()">修改</button>
                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="exampleModalInsert" tabindex="-1" role="dialog"
             aria-labelledby="exampleModalInsertLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">×</span></button>
                        <h4 class="modal-title" id="exampleModalInsertLabel">新增消息</h4>
                    </div>
                    <form role="form">
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="istatus">状态</label>
                                <select class="form-control " id="istatus">
                                    <option value="0">禁用</option>
                                    <option value="1" selected>启用</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="imessage">消息</label>
                                <textarea class="form-control" rows="3" id="imessage"></textarea>
                            </div>
                        </div>
                    </form>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" onclick="InsertDate()">提交</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
</body>
<script>
    var recipient;
    $('#exampleModal').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget) // 触发事件的按钮
        recipient = button.data('whatever') // 解析出data-whatever内容
        $.ajax({
            url: "/mall/detail_message?messId=" + recipient,
            type: "GET",
            dataType: "json",
            success: function (json) {
                 $("#umessage").text(json.data.message);
                 $("#ustatus").val(json.data.status);
            }, error: function () {
                alert("请求失败");
            }
        });
    });

    $('#exampleModalInsert').on('show.bs.modal', function (event) {
    });
</script>
</html>